<template>
  <div>
    <!--  通知公告  全部  -->
<!--    <el-page-header @back="goBack" title="行政" content="通知公告" ></el-page-header>-->
    <!--  分割线  -->
    <el-divider class="head"></el-divider>

    <!--    高级查询-->
    <el-row>
      <el-form :inline="true" :model="AdmNoticeForm" >

        <el-col :span="2.5">
          <el-form-item>
            <el-input v-model="AdmNoticeForm.title" placeholder="请输入标题"></el-input>
          </el-form-item>
        </el-col>

        <el-col :span="2.5">
          <el-form-item label="开始时间:">
            <el-date-picker
                v-model="AdmNoticeForm.StartNoticeNotificationtime"
                type="datetime"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss "
                placeholder="选择开始时间">
            </el-date-picker>
          </el-form-item>
        </el-col>

        <el-col :span="2.5">
          <el-form-item label="结束时间:">
            <el-date-picker
                v-model="AdmNoticeForm.EndNoticeNotificationtime"
                type="datetime"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-DD HH:mm:ss"
                placeholder="选择结束时间">
            </el-date-picker>
          </el-form-item>
        </el-col>


        <el-col :span="2">
          <el-form-item>
            <el-button type="primary" plain @click="queryAdmNotice" icon="el-icon-search">检索</el-button>
          </el-form-item>
        </el-col>

        <el-col :span="2">
          <el-form-item>
            <el-button type="primary" plain @click="addAdmNotice" >添加</el-button>
          </el-form-item>
        </el-col>

      </el-form>

    </el-row>


    <el-table
        :data="AdmNoticeAllData"
        style="width: 100%">
      <el-table-column
          prop="title"
          label="标题">
      </el-table-column>
      <el-table-column
          prop="noticeNotificationtime"
          label="时间">
      </el-table-column>
      <el-table-column
          label="操作">

        <template slot-scope="scope">

          <el-dropdown placement="bottom" trigger="click">
            <el-button type="text" size="small">操作</el-button>
            <el-dropdown-menu slot="dropdown">

              <el-dropdown-item  @click.native="queryAdmNoticeByid(scope.row.id)">查看</el-dropdown-item>
              <el-dropdown-item  @click.native="updateBtn(scope.row.id)">修改</el-dropdown-item>
              <el-dropdown-item @click.native="delAdmNoticeByid(scope.row.id)">删除</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>


        </template>

      </el-table-column>
    </el-table>

    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-sizes="[2, 4, 6, 8]"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pageData.total">
    </el-pagination>


  </div>
</template>

<script>
export default {
  name: "AdmNoticeAll",
  data(){
    return{
      pageData:{},// 存放分页数据
      AdmNoticeAllData:[], // 表格数据
      AdmNoticeForm: {
        pageCur: "1",//页码
        pageSize: "2",//每页显示多少
        StartNoticeNotificationtime: "",// 通知开启时间
        EndNoticeNotificationtime: "", // 通知结束时间
        type:"getAll", // 标识查询全部
      },// 高查表单数据
    }
  },
  created() {
    this.queryAdmNotice()
  },
  methods:{
    handleSizeChange(val){
      this.AdmNoticeForm.pageSize=val
      this.queryAdmNotice();
    },
    handleCurrentChange(val){
      this.AdmNoticeForm.pageCur=val
      this.queryAdmNotice()

    },
    goBack() {
      this.$router.go(-1)
    },// 返回按钮
    queryAdmNotice() {
      const loading = this.$loading({
        lock: true,
        text: '正在载入...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      // console.log(this.AdmNoticeForm)
      this.$http.get("admNotice", {params: this.AdmNoticeForm})
          .then(res => {

            setTimeout(() => {
              loading.close();
            });

            this.AdmNoticeAllData = res.data.data.list
            this.pageData = res.data.data
          })
          .catch()
    },
    queryAdmNoticeByid(id) { // 查看公告详情
      this.$router.push({name:"queryadmnoticebyid",params:{id:id}})
    },
    delAdmNoticeByid(id){// 删除
      this.$confirm("确定删除", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
          .then(() => {

            const loading = this.$loading({
              lock: true,
              text: '正在载入...',
              spinner: 'el-icon-loading',
              background: 'rgba(0, 0, 0, 0.7)'
            });

           this.$http.delete(`admNotice/${id}`)
            .then( () => {

              setTimeout(() => {
                loading.close();
              });

              this.$message({
                message: '删除成功!',
                type: 'success'
              });
              this.queryAdmNotice()
            } )
            .catch()
          })
          .catch(() => {});
    },
    addAdmNotice(){// 添加
this.$router.push({name:"updateadmnotice"})
    },
    updateBtn(id){
      this.$router.push({name:"updateadmnotice",params:{id:id}})
    },// 修改
  }
}
</script>

<style scoped>
.head{
  margin-top: 10px ;
  margin-bottom: 15px ;
  height: 2px;
}
</style>